Skip to content

VSB-TUO/fix(cypress): stabilize login flow and hide Klaro consent banner in e…#1296

Merged
milanmajchrak merged 7 commits into
customer/vsb-tuofrom
fix/integration-tests
Jun 8, 2026
Merged

VSB-TUO/fix(cypress): stabilize login flow and hide Klaro consent banner in e…#1296
milanmajchrak merged 7 commits into
customer/vsb-tuofrom
fix/integration-tests

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Hardens the Cypress login flow on customer/vsb-tuo and documents the root cause of remaining red CI runs, which lives in the backend Docker image, not in this repository.

Frontend changes (this PR)

  • cypress/support/commands.ts:
    • replaced the brittle UI form-fill login with a programmatic cy.request('POST', '/api/authn/login') that mirrors the working pattern already used by cy.generateViewEvent(), sets the dsAuthInfo cookie directly, then triggers a single reload.
    • same approach applied to both cy.login() and the helper loginViaForm().
  • cypress/support/e2e.ts:
    • pre-seeds the Klaro consent cookie (services: authentication, preferences, acknowledgement, google-analytics, google-recaptcha, accessibility) so the banner never renders.
    • hides any residual .klaro DOM via injected CSS at window:before:load.
    • clears DSPACE-XSRF-COOKIE in beforeEach so each test gets a fresh CSRF round-trip.

These changes match the conventions used on green sibling branches (customer/lindat, customer/zcu-*, customer/uk, customer/sav, customer/TUL).

Why CI is still red on this PR — and what is not in scope

The frontend cannot make the tests green on its own because the backend image used by this branch does not respond to POST /api/authn/login on CI.

Evidence

  1. After the programmatic-login change, the CI screenshot for every failing spec still shows
    cy.request POST http://127.0.0.1:8080/server/api/authn/login pending until the 120 s timeout — i.e. no HTTP response at all, not a 401/403.

  2. Anonymous specs that issue the same cy.request POST pattern against the same backend (e.g. homepage-statistics.cy.ts → POST /api/statistics/viewevents) pass. Only /api/authn/login hangs.

  3. Build workflow history on the parent customer/vsb-tuo branch is failure on every run for the last several days, long before this PR existed.

  4. Diff of .github/workflows/build.yml between customer/vsb-tuo and every green sibling branch yields a single relevant difference:

    Branch DSPACE_CI_IMAGE Build CI
    customer/lindat, customer/uk, customer/sav, customer/zcu-pub, customer/zcu-data, customer/TUL dataquest/dspace:dspace-7_x-test green
    customer/vsb-tuo (this branch) dataquest/dspace:customer-vsb-tuo-test red

Conclusion

The Docker image dataquest/dspace:customer-vsb-tuo-test has a broken authentication endpoint (most likely an authentication method in the chain — LDAP / Shibboleth or similar — that blocks on a network connection that does not exist on the CI runner). This must be fixed in the DSpace backend repository / image build, not here.

Suggested backend follow-up

Override the authentication chain on CI to password-only, either by rebuilding the image with a CI-safe authentication.cfg, or by adding to docker/docker-compose-ci.yml under the dspace service environment: block:

plugin__P__sequence__P__org__P__dspace__P__authenticate__P__AuthenticationMethod: org.dspace.authenticate.PasswordAuthentication

(only after confirming the customer image honours __P__ → . env-var substitution).

Validation

  • Local Cypress: login/Klaro regressions resolved; remaining local failures are data-dependent (e.g. admin-workflow-page, submission) and not related to login or consent.
  • CI: still red on this branch due to the backend issue above. Tests will go green automatically once the customer backend image is fixed; no further frontend change can unblock them.

Copilot AI review requested due to automatic review settings May 25, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce Cypress e2e flakiness by making the login helper deterministic and preventing the Klaro consent overlay from intercepting clicks during test runs.

Changes:

  • Stabilize cy.loginViaForm() by intercepting POST /api/authn/login, waiting for a 200 response, and asserting redirect away from /login.
  • Extend the pre-agreed Klaro consent cookie to include accessibility and inject CSS on each page load to hide the .klaro banner.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cypress/support/e2e.ts Updates Klaro consent cookie and injects a style rule to hide the Klaro banner on page load.
cypress/support/commands.ts Makes form-based login deterministic via intercept + wait + redirect assertion, and scopes selectors to visible login form.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cypress/support/commands.ts
Comment thread cypress/support/e2e.ts Outdated
…on CI

CI evidence (run 26398927955) shows every login-protected spec failing with:
  'cy.wait() timed out waiting 30000ms for the 1st response to the route:
   loginRequest. No response ever occurred.'

The browser-side POST /api/authn/login dispatched from the Angular login
form does not receive a response within Cypress' default 30s wait on the
ubuntu-latest runner, while anonymous specs (23/55) pass. Switching to
cy.request() drives the login from the Cypress (Node) side directly against
the backend, bypassing CORS/XSRF/SSR timing problems, and writes the
resulting auth token into the same UI cookie Angular reads on bootstrap.
A subsequent cy.reload() rehydrates Angular as an authenticated user and
preserves the original returnUrl for specs that visit a restricted page
first (e.g. /mydspace, /submit).

Also addresses Copilot review feedback on the prior attempt: removes the
hard cy.wait(500) and encodes the klaro-anonymous cookie via
JSON.stringify + encodeURIComponent.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d4724fb-2e8d-40c9-bce6-2c8e2eb7c9fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

milanmajchrak and others added 4 commits June 8, 2026 16:05
With the backend auth-chain fix (PasswordAuthentication first) the admin
login no longer hangs, so the programmatic cy.request() login introduced
earlier is unnecessary. That programmatic login also left specs which
start on /login stranded there (the injected auth cookie did not trigger
the app's away-from-login redirect), failing ~17 login-gated specs with
"expected '/login' not to match". Reverting to the proven form-based
login fixes those.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
These VSB/CLARIN pages render slower than Cypress' 4s default, which
caused the last two failures after the login fix:

- submission: the CLARIN submission form loads several controlled
  vocabularies before the metadata fields appear, so input#dc_title was
  not yet in the DOM. Wait for ds-submission-edit and give dc_title a
  generous timeout. After a failed deposit the metadata accordion section
  can collapse (ngb-accordion drops its body), so re-expand it before
  asserting the title field is invalid.
- admin-workflow: the supervision-configured search can take a while to
  return on a freshly started backend; allow extra time for the first
  list-object to render.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The submission spec failed on `input#dc_title` even with a generous
timeout because it was never a timing problem: VSB configures dc.title
with input type "textarea" (upstream uses "onebox"), so the field renders
as <textarea id="dc_title">, which `input#dc_title` never matches. Use the
tag-agnostic id selector `#dc_title` instead. (admin-workflow, which was a
genuine slow-render case, is already green from the previous timeout bump.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ission deposit test

After fixing the title selector, the deposit test reached the CLARIN
resource-license *selector* (ds-submission-section-clarin-license). That
section is not part of the "Sample Collection" traditional submission form
(which only includes the distribution-license section, already toggled), so
those steps could never pass here. Comment them out, consistent with the
other inapplicable CLARIN steps already disabled in this file. The test
still covers title/date, distribution-license acceptance and file upload.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@milanmajchrak milanmajchrak merged commit 47b14cc into customer/vsb-tuo Jun 8, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants